home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / elm / elm2.4 / src / help.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-11  |  12.8 KB  |  397 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: help.c,v 5.3 1993/04/12 03:15:41 syd Exp $";
  3.  
  4. /*******************************************************************************
  5.  *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
  6.  *
  7.  *            Copyright (c) 1988-1992 USENET Community Trust
  8.  *            Copyright (c) 1986,1987 Dave Taylor
  9.  *******************************************************************************
  10.  * Bug reports, patches, comments, suggestions should be sent to:
  11.  *
  12.  *    Syd Weinstein, Elm Coordinator
  13.  *    elm@DSI.COM            dsinc!elm
  14.  *
  15.  *******************************************************************************
  16.  * $Log: help.c,v $
  17.  * Revision 5.3  1993/04/12  03:15:41  syd
  18.  * These patches makes 'T' (since it was free) do a Tag and Move command in the
  19.  * index and alias page, and in the builtin pager.
  20.  * In the alias help in src/alias.c, there is a tolower done on the character
  21.  * one wants help for.  This is clearly wrong.
  22.  * From: Jan Djarv <Jan.Djarv@sa.erisoft.se>
  23.  *
  24.  * Revision 5.2  1993/01/20  03:37:16  syd
  25.  * Nits and typos in the NLS messages and corresponding default messages.
  26.  * From: dwolfe@pffft.sps.mot.com (Dave Wolfe)
  27.  *
  28.  * Revision 5.1  1992/10/03  22:58:40  syd
  29.  * Initial checkin as of 2.4 Release at PL0
  30.  *
  31.  *
  32.  ******************************************************************************/
  33.  
  34. /*** help routine for ELM program 
  35.  
  36. ***/
  37.  
  38. #include <ctype.h>
  39. #include "headers.h"
  40. #include "s_elm.h"
  41.  
  42. help(pager_help)
  43. int pager_help;
  44. {
  45.     /** Process the request for help [section] from the user.
  46.         If pager_help is TRUE, then act a little differently from
  47.         if pager_help is FALSE (index screen)
  48.      **/
  49.  
  50.     char ch;        /* character buffer for input */
  51.     char *s;        /* string pointer...          */
  52.     int prompt_line, info_line;
  53.     static char *help_message = NULL;
  54.     static char *help_prompt = NULL;
  55.     static char *unknown_command = NULL;
  56.  
  57.     if (help_message == NULL) {
  58.         help_message = catgets(elm_msg_cat, ElmSet, ElmHelpMessage,
  59.    "Press the key you want help for, '?' for a key list, or '.' to exit help");
  60.         help_prompt = catgets(elm_msg_cat, ElmSet, ElmHelpPrompt,
  61.             "Help for key: ");
  62.         unknown_command = catgets(elm_msg_cat, ElmSet, ElmHelpUnknownCommand,
  63.               "Unknown command.  Use '?' for a list of commands.");
  64.     }
  65.  
  66.     MoveCursor(LINES-4,0);
  67.     CleartoEOS();
  68.  
  69.     if(pager_help) {
  70.       put_border();
  71.       Centerline(LINES, help_message);
  72.       prompt_line = LINES-3;
  73.     } else {
  74.       Centerline(LINES-4, catgets(elm_msg_cat, ElmSet, ElmHelpSystem,
  75.         "ELM Help System"));
  76.       Centerline(LINES-3, help_message);
  77.       prompt_line = LINES-2;
  78.     }
  79.     info_line = prompt_line + 1;
  80.  
  81.     PutLine0(prompt_line, 0, help_prompt);
  82.  
  83.     do {
  84.       MoveCursor(prompt_line, strlen(help_prompt));
  85.       ch = ReadCh();
  86.       
  87.       if (ch == '.') return(0);    /* zero means footer rewrite only */
  88.  
  89.       s = unknown_command;
  90.  
  91.       switch (ch) {
  92.  
  93.         case '?': display_helpfile(pager_help? PAGER_HELP : MAIN_HELP);
  94.               return(1);
  95.  
  96.         case '$': if(!pager_help) s = catgets(elm_msg_cat, ElmSet, ElmHelpDollar,
  97. "$ = Force resynchronization of the current folder. This will purge deleted mail.");
  98.               break;
  99.  
  100.         case '!': s = catgets(elm_msg_cat, ElmSet, ElmHelpShell,
  101.      "! = Escape to the UNIX shell of your choice, or just to enter commands.");
  102.                   break;
  103.  
  104.         case '@': if(!pager_help) s = catgets(elm_msg_cat, ElmSet, ElmHelpDebugSummary,
  105.        "@ = Debug - display a summary of the messages on the header page.");
  106.               break;
  107.  
  108.         case '|': s = catgets(elm_msg_cat, ElmSet, ElmHelpPipe,
  109.    "| = Pipe the current message or tagged messages to the command specified.");
  110.               break;
  111.  
  112.         case '#': if(!pager_help) s = catgets(elm_msg_cat, ElmSet, ElmHelpDebugAll,
  113.         "# = Debug - display all information known about current message.");
  114.               break;
  115.  
  116.         case '%': s = catgets(elm_msg_cat, ElmSet, ElmHelpDebugReturnAdd,
  117.      "% = Debug - display the computed return address of the current message.");
  118.               break;
  119.  
  120.         case '*': if(!pager_help)
  121.                s = catgets(elm_msg_cat, ElmSet, ElmHelpLastMessage,
  122.                 "* = Go to the last message in the current folder.");
  123.               break;
  124.  
  125.         case '-': if(!pager_help) s = catgets(elm_msg_cat, ElmSet, ElmHelpPreviousPage,
  126. "- = Go to the previous page of messages.  This is the same as the LEFT arrow.");
  127.               break;
  128.  
  129.         case '=': if(!pager_help) s = catgets(elm_msg_cat, ElmSet, ElmHelpFirstMessage,
  130.             "'=' = Go to the first message in the current folder.");
  131.               break;
  132.  
  133.         case ' ': if(pager_help)
  134.             s = catgets(elm_msg_cat, ElmSet, ElmHelpNextScreen,
  135.   "<space> = Display next screen of current message (or first screen of next).");
  136.               else
  137.             s = catgets(elm_msg_cat, ElmSet, ElmHelpDisplayCurrent,
  138.                 "<space> = Display the current message.");
  139.               break;
  140.  
  141.         case '+': if(!pager_help)
  142.                 s = catgets(elm_msg_cat, ElmSet, ElmHelpNextPage,
  143.   "+ = Go to the next page of messages.  This is the same as the RIGHT arrow.");
  144.               break;
  145.  
  146.         case '/': if(!pager_help)
  147.             s = catgets(elm_msg_cat, ElmSet, ElmHelpSearchFolder,
  148.                 "/ = Search for specified pattern in folder.");
  149.               break;
  150.  
  151. #ifdef ENABLE_CALENDAR
  152.         case '<': s = catgets(elm_msg_cat, ElmSet, ElmHelpCalendar,
  153.            "< = Scan current message for calendar entries (if enabled).");
  154.               break;
  155. #endif
  156.  
  157.         case '>': s = catgets(elm_msg_cat, ElmSet, ElmHelpSave,
  158.            "> = Save current message or tagged messages to specified file.");
  159.               break;
  160.  
  161.         case '^': if(!pager_help) s = catgets(elm_msg_cat, ElmSet, ElmHelpToggleStatus,
  162.            "^ = Toggle the Delete/Undelete status of the current message.");
  163.               break;
  164.  
  165.         case 'a': if(!pager_help) s = catgets(elm_msg_cat, ElmSet, ElmHelpAliasSubmenu,
  166.        "a = Enter the alias sub-menu section.  Create and display aliases.");
  167.               break;
  168.  
  169.         case 'b': s = catgets(elm_msg_cat, ElmSet, ElmHelpBounce,
  170.       "b = Bounce (remail) a message to someone as if you have never seen it.");
  171.               break;
  172.  
  173.         case 'C': s = catgets(elm_msg_cat, ElmSet, ElmHelpCopy,
  174.                "C = Copy current message or tagged messages to specified file.");
  175.               break;
  176.  
  177.         case 'c': if(!pager_help)
  178.                 s = catgets(elm_msg_cat, ElmSet, ElmHelpChangeFolder,
  179.      "c = Change folders, leaving the current folder as if 'quitting'.");
  180.               break;
  181.  
  182.         case 'd': s = catgets(elm_msg_cat, ElmSet, ElmHelpDelete,
  183.             "d = Mark the current message for future deletion.");
  184.               break;
  185.  
  186.         case ctrl('D') : if(!pager_help) s = catgets(elm_msg_cat, ElmSet, ElmHelpDeletePattern,
  187.           "^D = Mark for deletion all messages with the specified pattern.");
  188.               break;
  189.  
  190. #ifdef ALLOW_MAILBOX_EDITING
  191.         case 'e': if(!pager_help) s = catgets(elm_msg_cat, ElmSet, ElmHelpEditor,
  192.      "e = Invoke the editor on the entire folder, resynchronizing when done.");
  193.               break;
  194. #endif
  195.  
  196.         case 'f': s = catgets(elm_msg_cat, ElmSet, ElmHelpForward,
  197.     "f = Forward the current message to someone, return address is yours.");
  198.               break;
  199.  
  200.         case 'g': s = catgets(elm_msg_cat, ElmSet, ElmHelpGroupReply,
  201.    "g = Group reply not only to the sender, but to everyone who received msg.");
  202.               break;
  203.  
  204.         case 'h': s = catgets(elm_msg_cat, ElmSet, ElmHelpDisplayHeaders,
  205.          "h = Display message with all Headers (ignore weedout list).");
  206.                   break;
  207.  
  208.         case 'i': if(pager_help)
  209.             s = catgets(elm_msg_cat, ElmSet, ElmHelpReturnToIndex,
  210.                 "i = Return to the index.");
  211.               break;
  212.  
  213.         case 'J': s = catgets(elm_msg_cat, ElmSet, ElmHelpNextMessage,
  214.             "J = Go to the next message.");
  215.               break;
  216.  
  217.         case 'j': s = catgets(elm_msg_cat, ElmSet, ElmHelpNextUndeleted,
  218.   "j = Go to the next undeleted message.  This is the same as the DOWN arrow.");
  219.               break;
  220.  
  221.         case 'K': s = catgets(elm_msg_cat, ElmSet, ElmHelpPreviousMessage,
  222.             "K = Go to the previous message.");
  223.               break;
  224.  
  225.         case 'k': s = catgets(elm_msg_cat, ElmSet, ElmHelpPreviousUndeleted,
  226. "k = Go to the previous undeleted message.  This is the same as the UP arrow.");
  227.               break;
  228.  
  229.         case 'l': if(!pager_help)
  230.             s = catgets(elm_msg_cat, ElmSet, ElmHelpLimitDisplay,
  231.                "l = Limit displayed messages based on the specified criteria.");
  232.               break;
  233.  
  234.         case 'm': s = catgets(elm_msg_cat, ElmSet, ElmHelpSendMail,
  235.          "m = Create and send mail to the specified person or persons.");
  236.               break;
  237.  
  238.         case 'n': if(pager_help)
  239.             s = catgets(elm_msg_cat, ElmSet, ElmHelpDisplayNext,
  240.                 "n = Display the next message.");
  241.               else
  242.             s = catgets(elm_msg_cat, ElmSet, ElmHelpDisplayThenNext,
  243.        "n = Display the current message, then move current to next message.");
  244.               break;
  245.  
  246.         case 'o': if(!pager_help)
  247.             s = catgets(elm_msg_cat, ElmSet, ElmHelpOptionsMenu,
  248.                 "o = Go to the options submenu.");
  249.                   break;
  250.  
  251.         case 'p': s = catgets(elm_msg_cat, ElmSet, ElmHelpPrint,
  252.               "p = Print the current message or the tagged messages.");
  253.                   break;
  254.  
  255.         case 'q': if(pager_help)
  256.             s = catgets(elm_msg_cat, ElmSet, ElmHelpQuitPager,
  257.               "q = Quit the pager and return to the index.");
  258.               else s = catgets(elm_msg_cat, ElmSet, ElmHelpQuitMailer,
  259.             "q = Quit the mailer, asking about deletion, saving, etc.");
  260.               break;
  261.  
  262.         case 'r': s = catgets(elm_msg_cat, ElmSet, ElmHelpReplyMessage,
  263. "r = Reply to the message.  This only sends to the originator of the message.");
  264.                   break;
  265.  
  266.         case 's': s = catgets(elm_msg_cat, ElmSet, ElmHelpSaveMessage,
  267.                "s = Save current message or tagged messages to specified file.");
  268.               break;
  269.  
  270.         case 't': s = catgets(elm_msg_cat, ElmSet, ElmHelpTagMessage,
  271.                "t = Tag a message for further operations (or untag if tagged).");
  272.               break;
  273.  
  274.         case 'T': s = catgets(elm_msg_cat, ElmSet, ElmHelpTagAndNext,
  275.                "T = Tag a message (or untag if tagged) and go to next message.");
  276.               break;
  277.  
  278.         case ctrl('T') : if(!pager_help)
  279.             s = catgets(elm_msg_cat, ElmSet, ElmHelpTagPattern,
  280.                 "^T = Tag all messages with the specified pattern.");
  281.               break;
  282.  
  283.         case 'u': s = catgets(elm_msg_cat, ElmSet, ElmHelpUndeleteMessage,
  284.               "u = Undelete - remove the deletion mark on the message.");
  285.               break;
  286.  
  287.         case ctrl('U') : s = catgets(elm_msg_cat, ElmSet, ElmHelpUndeletePattern,
  288.               "^U = Undelete all messages with the specified pattern.");
  289.               break;
  290.  
  291.         case 'x': s = catgets(elm_msg_cat, ElmSet, ElmHelpExitFolder,
  292.             "x = Exit leaving the folder untouched, ask permission if changed.");
  293.               break;
  294.  
  295.         case 'X': s = catgets(elm_msg_cat, ElmSet, ElmHelpQuickExit,
  296.             "X = Exit leaving the folder untouched, unconditionally.");
  297.               break;
  298.  
  299.         case 'Q': if(!pager_help)
  300.             s = catgets(elm_msg_cat, ElmSet, ElmHelpQuickQuit,
  301.         "Q = Quick quit the mailer, save read, leave unread, delete deleted.");
  302.               break;
  303.  
  304.         case '\n':
  305.         case '\r': if(pager_help)
  306.              s = catgets(elm_msg_cat, ElmSet, ElmHelpScrollForward,
  307.   "<return> = Display current message, or (builtin pager only) scroll forward.");
  308.                else
  309.              s = catgets(elm_msg_cat, ElmSet, ElmHelpDisplayCurrentMessage,
  310.                 "<return> = Display the current message.");
  311.                break;
  312.  
  313.         case ctrl('L'): if(!pager_help)
  314.             s = catgets(elm_msg_cat, ElmSet, ElmHelpRewriteScreen,
  315.                 "^L = Rewrite the screen.");    
  316.                break;
  317.  
  318.             case ctrl('?'):                        /* DEL */
  319.         case ctrl('Q'): if(!pager_help)
  320.                 s = catgets(elm_msg_cat, ElmSet, ElmHelpExitQuickly,
  321.                     "Exit the mail system quickly.");
  322.                break;
  323.  
  324.         default : if (isdigit(ch) && !pager_help) 
  325.                 s = catgets(elm_msg_cat, ElmSet, ElmHelpMakeMessageCurrent,
  326.             "<number> = Make specified number the current message.");
  327.       }
  328.  
  329.       ClearLine(info_line);
  330.       Centerline(info_line, s);
  331.  
  332.     } while (ch != '.');
  333.     
  334.     /** we'll never actually get here, but that's okay... **/
  335.  
  336.     return(0);
  337. }
  338.  
  339. display_helpfile(section)
  340. int section;
  341. {
  342.     /*** Help me!  Read file 'helpfile.<section>' and echo to screen ***/
  343.  
  344.     char buffer[SLEN];
  345.  
  346.     sprintf(buffer, "%s/%s.%d", helphome, helpfile, section);
  347.     return(display_file(buffer));
  348. }
  349.  
  350. display_file(file)
  351. char *file;
  352. {
  353.     /*** Display file to screen ***/
  354.  
  355.     FILE *fileptr;
  356.     int  lines=0;
  357.     char buffer[SLEN];
  358.  
  359.     if ((fileptr = fopen(file,"r")) == NULL) {
  360.       dprint(1, (debugfile,
  361.          "Error: Couldn't open file %s (help)\n", file));
  362.       error1(catgets(elm_msg_cat, ElmSet, ElmHelpCouldntOpenFile,
  363.         "Couldn't open file %s."), file);
  364.       return(FALSE);
  365.     }
  366.     
  367.     ClearScreen();
  368.  
  369.     while (fgets(buffer, SLEN, fileptr) != NULL) {
  370.       if (lines > LINES-3) {
  371.         PutLine0(LINES, 0, catgets(elm_msg_cat, ElmSet, ElmHelpPressSpaceToContinue,
  372.         "Press <space> to continue, 'q' to return."));
  373.         if(ReadCh() == 'q') {
  374.           clear_error();
  375.           fclose(fileptr);
  376.           return(TRUE);
  377.         }
  378.         lines = 0;
  379.         ClearScreen();
  380.         Write_to_screen("%s\r", 1, buffer);
  381.       }
  382.       else 
  383.         Write_to_screen("%s\r", 1, buffer);
  384.  
  385.       lines += strlen(buffer)/COLUMNS + 1;
  386.     }
  387.  
  388.         PutLine0(LINES, 0, catgets(elm_msg_cat, ElmSet, ElmHelpPressAnyKeyToReturn,
  389.         "Press any key to return."));
  390.  
  391.     (void) ReadCh();
  392.     clear_error();
  393.  
  394.     fclose(fileptr);
  395.     return(TRUE);
  396. }
  397.